package com.esunny.online.service.impl;

import com.esunny.online.dao.UserDao;
import com.esunny.online.domain.entity.User;
import com.esunny.online.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author ：李先生
 * @date ：Created in 2020/7/18 8:43
 * @description： UserService实现类
 * @modified By：
 * @version: $
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    /**
     * 登录功能
     *
     * @param map 封装数据
     * @return JSON字符串
     */
    @Override
    public User login(Map<String, Object> map) {
        String username = (String) map.get("username");
        String password = (String) map.get("password");

        User user = userDao.selectByNameAndPass(username, password);

        return user;

    }

    /**
     * 根据用户名查找对象
     *
     * @param username 用户名
     * @return User
     */
    @Override
    public User selectByName(String username) {

        return userDao.selectByName(username);
    }


}
